<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Skilful: Исходный файл Skilful/MT4control.cs</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Создано системой Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Поиск');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Титульная&nbsp;страница</span></a></li>
      <li><a href="namespaces.html"><span>Пакеты</span></a></li>
      <li><a href="annotated.html"><span>Классы</span></a></li>
      <li class="current"><a href="files.html"><span>Файлы</span></a></li>
      <li><a href="dirs.html"><span>Алфавитный&nbsp;указатель&nbsp;директорий</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Поиск" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Файлы</span></a></li>
    </ul>
  </div>
  <div class="navpath">
    <ul>
      <li><a class="el" href="dir_7adcdc1edff7620168fbc20357cad448.html">Skilful</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<h1>MT4control.cs</h1>  </div>
</div>
<div class="contents">
<a href="_m_t4control_8cs.html">См. документацию.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ﻿<span class="comment">//---------------------------------------------------------------------------------------------------------------</span>
<a name="l00002"></a>00002 <span class="comment">// Skilful. Tactica Adversa graphic and analysis tool.</span>
<a name="l00003"></a>00003 <span class="comment">// Copyright (C) 2010 &quot;...&quot;, Isabek Satybekov</span>
<a name="l00004"></a>00004 <span class="comment">//</span>
<a name="l00005"></a>00005 <span class="comment">// This program is free software; you can redistribute it and/or</span>
<a name="l00006"></a>00006 <span class="comment">// modify it under the terms of the GNU General Public License</span>
<a name="l00007"></a>00007 <span class="comment">// as published by the Free Software Foundation; either version 2</span>
<a name="l00008"></a>00008 <span class="comment">// of the License, or (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment">//</span>
<a name="l00010"></a>00010 <span class="comment">// This program is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00013"></a>00013 <span class="comment">// GNU General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment">//</span>
<a name="l00015"></a>00015 <span class="comment">// You should have received a copy of the GNU General Public License</span>
<a name="l00016"></a>00016 <span class="comment">// along with this program; if not, write to the Free Software</span>
<a name="l00017"></a>00017 <span class="comment">// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.</span>
<a name="l00018"></a>00018 <span class="comment">//</span>
<a name="l00019"></a>00019 <span class="comment">// mail: support@protoforma.com </span>
<a name="l00020"></a>00020 <span class="comment">//---------------------------------------------------------------------------------------------------------------</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="keyword">using</span> System;
<a name="l00024"></a>00024 <span class="keyword">using</span> System.Collections.Generic;
<a name="l00025"></a>00025 <span class="keyword">using</span> System.ComponentModel;
<a name="l00026"></a>00026 <span class="keyword">using</span> System.Data;
<a name="l00027"></a>00027 <span class="keyword">using</span> System.Drawing;
<a name="l00028"></a>00028 <span class="keyword">using</span> System.Linq;
<a name="l00029"></a>00029 <span class="keyword">using</span> System.Text;
<a name="l00030"></a>00030 <span class="keyword">using</span> System.Windows.Forms;
<a name="l00031"></a>00031 <span class="keyword">using</span> Skilful.Data;
<a name="l00032"></a>00032 <span class="keyword">using</span> Skilful;
<a name="l00033"></a>00033 <span class="keyword">using</span> System.IO;
<a name="l00034"></a>00034 <span class="keyword">using</span> System.Threading;
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="keyword">namespace </span>Skilful
<a name="l00038"></a>00038 {
<a name="l00039"></a><a class="code" href="class_skilful_1_1_m_t4control.html">00039</a>     <span class="keyword">public</span> <span class="keyword">partial class </span><a class="code" href="class_skilful_1_1_m_t4control.html">MT4control</a> : Form
<a name="l00040"></a>00040     {
<a name="l00041"></a><a class="code" href="class_skilful_1_1_m_t4control.html#ae3ef9015f6418b0e2d99452d4dfa1e6d">00041</a>         <span class="keyword">public</span> <a class="code" href="class_skilful_1_1_m_t4control.html#ae3ef9015f6418b0e2d99452d4dfa1e6d">MT4control</a>(<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html">MTproxy</a> mtproxy)
<a name="l00042"></a>00042         {
<a name="l00043"></a>00043             InitializeComponent();
<a name="l00044"></a>00044             this.mtproxy = mtproxy;
<a name="l00045"></a>00045         }
<a name="l00046"></a>00046         <a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html">MTproxy</a> mtproxy;
<a name="l00047"></a>00047 
<a name="l00051"></a>00051         <span class="keyword">private</span> <span class="keyword">const</span> <span class="keywordtype">string</span> delimiter = <span class="stringliteral">&quot;|&quot;</span>;
<a name="l00052"></a>00052         
<a name="l00053"></a>00053         <span class="keyword">private</span> <span class="keywordtype">void</span> button1_Click(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00054"></a>00054         {
<a name="l00055"></a>00055             <span class="comment">//будем считать что список инструментов обновлен по нажатию этой кнопки,</span>
<a name="l00056"></a>00056             <span class="comment">//при этом оставшиеся файлы от старого списка использоваться больше никогда не будут (они имеют уникальные номера)</span>
<a name="l00057"></a>00057             <span class="comment">//поэтому их можно смело удалять, и для стерильности так мы и сделаем;)</span>
<a name="l00058"></a>00058 
<a name="l00059"></a>00059             <span class="keywordtype">string</span> folder_path = <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>) + <span class="stringliteral">&quot;\\experts\\files\\&quot;</span>;
<a name="l00060"></a>00060             DirectoryInfo di = <span class="keyword">new</span> DirectoryInfo(folder_path);
<a name="l00061"></a>00061             FileInfo[] filelist = di.GetFiles(<span class="stringliteral">&quot;*&#39;?&#39;?&quot;</span>);
<a name="l00062"></a>00062             <span class="keywordflow">foreach</span> (FileInfo fi <span class="keywordflow">in</span> filelist)
<a name="l00063"></a>00063             {
<a name="l00064"></a>00064                 <span class="keywordtype">bool</span> save=<span class="keyword">false</span>;
<a name="l00065"></a>00065                 <span class="keywordtype">string</span> symbolname = fi.Name.Split(<span class="charliteral">&#39;\&#39;&#39;</span>)[0];
<a name="l00066"></a>00066                 <span class="keywordflow">foreach</span>(<span class="keywordtype">string</span> item <span class="keywordflow">in</span> checkedListBox1.CheckedItems){
<a name="l00067"></a>00067                     <span class="keywordflow">if</span>(item == symbolname){
<a name="l00068"></a>00068                         save=<span class="keyword">true</span>;
<a name="l00069"></a>00069                         <span class="keywordflow">break</span>;
<a name="l00070"></a>00070                     }
<a name="l00071"></a>00071                 }
<a name="l00072"></a>00072                 <span class="keywordflow">if</span> (!save)
<a name="l00073"></a>00073                 {
<a name="l00074"></a>00074                     fi.Delete();
<a name="l00075"></a>00075                     FileInfo[] csv = di.GetFiles(symbolname+<span class="stringliteral">&quot;*.csv&quot;</span>);
<a name="l00076"></a>00076                     <span class="keywordflow">foreach</span> (FileInfo f <span class="keywordflow">in</span> csv) f.Delete();
<a name="l00077"></a>00077                 }
<a name="l00078"></a>00078             }
<a name="l00079"></a>00079            
<a name="l00080"></a>00080             this.Close();
<a name="l00081"></a>00081         }
<a name="l00082"></a>00082 
<a name="l00088"></a>00088         <span class="keyword">private</span> <span class="keywordtype">void</span> MT4control_Load(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00089"></a>00089         {
<a name="l00090"></a>00090             checkedListBox1.CheckOnClick = <span class="keyword">true</span>;
<a name="l00091"></a>00091             folderBrowserDialog1.Description = <span class="stringliteral">&quot;Choose path to your MT4 terminal&quot;</span>;
<a name="l00092"></a>00092             folderBrowserDialog1.SelectedPath = <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>);
<a name="l00093"></a>00093             folderBrowserDialog1.ShowNewFolderButton = <span class="keyword">false</span>;
<a name="l00094"></a>00094             textBox1.Text = <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>);
<a name="l00095"></a>00095             <span class="keywordflow">if</span> (Directory.Exists(textBox1.Text))
<a name="l00096"></a>00096             {
<a name="l00097"></a>00097                 getAccounts();
<a name="l00098"></a>00098                 textBox2.Text = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00099"></a>00099                 mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a3588b6e2a02b1b9a9aab844d03f5d404">mt4init</a>();
<a name="l00100"></a>00100                 setList();
<a name="l00101"></a>00101             }
<a name="l00102"></a>00102             <span class="keywordflow">else</span>
<a name="l00103"></a>00103             {
<a name="l00104"></a>00104                 button1.Enabled = <span class="keyword">false</span>;
<a name="l00105"></a>00105                 textBox2.Text = <span class="stringliteral">&quot;Choose correct MT4 path&quot;</span>;
<a name="l00106"></a>00106             }
<a name="l00107"></a>00107 
<a name="l00108"></a>00108         }
<a name="l00109"></a>00109 
<a name="l00110"></a>00110         <span class="keyword">private</span> <span class="keywordtype">void</span> button2_Click(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00111"></a>00111         {
<a name="l00112"></a>00112             <span class="keywordflow">if</span> (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
<a name="l00113"></a>00113             {
<a name="l00114"></a>00114                 textBox1.Text = folderBrowserDialog1.SelectedPath;
<a name="l00115"></a>00115                 <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Set(<span class="stringliteral">&quot;MT4Path&quot;</span>, textBox1.Text);
<a name="l00116"></a>00116                 <span class="keywordflow">if</span> (Directory.Exists(textBox1.Text))
<a name="l00117"></a>00117                 {
<a name="l00118"></a>00118                     mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a51fc2343dc328bedc7bebbf2f88326ab">WriteWndHandle</a>(0);
<a name="l00119"></a>00119                     getAccounts();
<a name="l00120"></a>00120                     textBox2.Text = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00121"></a>00121                     mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a3588b6e2a02b1b9a9aab844d03f5d404">mt4init</a>();
<a name="l00122"></a>00122                     setList();
<a name="l00123"></a>00123                 }
<a name="l00124"></a>00124                 <span class="keywordflow">else</span>
<a name="l00125"></a>00125                 {
<a name="l00126"></a>00126                     button1.Enabled = <span class="keyword">false</span>;
<a name="l00127"></a>00127                     textBox2.Text = <span class="stringliteral">&quot;Choose correct MT4 path&quot;</span>;
<a name="l00128"></a>00128                 }
<a name="l00129"></a>00129 
<a name="l00130"></a>00130             }
<a name="l00131"></a>00131         }
<a name="l00132"></a>00132 
<a name="l00137"></a>00137         <span class="keyword">private</span> <span class="keywordtype">void</span> getAccounts()
<a name="l00138"></a>00138         {
<a name="l00139"></a>00139             <span class="keywordtype">string</span> mt4path = <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>) + <span class="stringliteral">&quot;\\config\\&quot;</span>;
<a name="l00140"></a>00140             <span class="keywordflow">if</span> (Directory.Exists(mt4path) == <span class="keyword">false</span>)
<a name="l00141"></a>00141             {
<a name="l00142"></a>00142                 listBox1.Items.Clear();
<a name="l00143"></a>00143                 checkedListBox1.Items.Clear();
<a name="l00144"></a>00144                 textBox2.Text = <span class="stringliteral">&quot;check mt4 path&quot;</span>;
<a name="l00145"></a>00145                 <span class="keywordflow">return</span>;
<a name="l00146"></a>00146             }
<a name="l00147"></a>00147             <span class="keywordtype">string</span>[] accounts = Directory.GetFiles(mt4path, <span class="stringliteral">&quot;*.srv&quot;</span>);
<a name="l00148"></a>00148             listBox1.Items.Clear();
<a name="l00149"></a>00149             <span class="keywordflow">foreach</span> (<span class="keywordtype">string</span> account <span class="keywordflow">in</span> accounts)
<a name="l00150"></a>00150                 listBox1.Items.Add(Path.GetFileNameWithoutExtension(account));
<a name="l00151"></a>00151             <span class="keywordtype">int</span> idx = listBox1.FindString(<a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4account&quot;</span>));
<a name="l00152"></a>00152             <span class="keywordflow">if</span> (idx &lt; 0) idx = 0;
<a name="l00153"></a>00153             <span class="keywordflow">if</span> (listBox1.Items.Count&gt;0) listBox1.SetSelected(idx, <span class="keyword">true</span>);
<a name="l00154"></a>00154         }
<a name="l00155"></a>00155 
<a name="l00162"></a>00162         <span class="keyword">private</span> <span class="keywordtype">void</span> textBox1_Leave(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00163"></a>00163         {
<a name="l00164"></a>00164             <span class="keywordflow">if</span> (textBox1.Text != <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>))
<a name="l00165"></a>00165             {
<a name="l00166"></a>00166                 <span class="comment">//textBox1.Text = &quot;new directory&quot;;</span>
<a name="l00167"></a>00167                 <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Set(<span class="stringliteral">&quot;MT4Path&quot;</span>,  textBox1.Text);
<a name="l00168"></a>00168                 <span class="keywordflow">if</span> (Directory.Exists(<a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>)))
<a name="l00169"></a>00169                 {
<a name="l00170"></a>00170                     mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a51fc2343dc328bedc7bebbf2f88326ab">WriteWndHandle</a>(0);
<a name="l00171"></a>00171                     getAccounts();
<a name="l00172"></a>00172                     textBox2.Text = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00173"></a>00173                     mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a3588b6e2a02b1b9a9aab844d03f5d404">mt4init</a>();
<a name="l00174"></a>00174                     setList();
<a name="l00175"></a>00175                 }
<a name="l00176"></a>00176                 <span class="keywordflow">else</span>
<a name="l00177"></a>00177                 {
<a name="l00178"></a>00178                     button1.Enabled = <span class="keyword">false</span>;
<a name="l00179"></a>00179                     textBox2.Text = <span class="stringliteral">&quot;Choose correct MT4 path&quot;</span>;
<a name="l00180"></a>00180                 }
<a name="l00181"></a>00181             }
<a name="l00182"></a>00182 
<a name="l00183"></a>00183         }
<a name="l00184"></a>00184 
<a name="l00191"></a>00191         <span class="keyword">private</span> <span class="keywordtype">void</span> listBox1_SelectedIndexChanged(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00192"></a>00192         {
<a name="l00193"></a>00193             <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Set(<span class="stringliteral">&quot;MT4account&quot;</span>, listBox1.SelectedItem.ToString());
<a name="l00194"></a>00194             checkedListBox1.Items.Clear();
<a name="l00195"></a>00195             <span class="keywordtype">string</span> symbolsPath = <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>) + <span class="stringliteral">&quot;\\history\\&quot;</span>
<a name="l00196"></a>00196                                  + (string)listBox1.SelectedItem + <span class="stringliteral">&quot;\\symbols.sel&quot;</span>;
<a name="l00197"></a>00197             if (File.Exists(symbolsPath) == <span class="keyword">true</span>)
<a name="l00198"></a>00198             {
<a name="l00199"></a>00199                 (this.Owner as <a class="code" href="class_skilful_1_1_main_form.html">MainForm</a>).DataManager.DataSource[<span class="stringliteral">&quot;MT4&quot;</span>].StoragePath = mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a54886ec28286d2b6a76b212a8ce18239">StoragePath</a>();
<a name="l00200"></a>00200                 
<a name="l00201"></a>00201                 <span class="keywordflow">if</span>((this.Owner as <a class="code" href="class_skilful_1_1_main_form.html">MainForm</a>).DataManager.Config.ContainsKey(<span class="stringliteral">&quot;MT4&quot;</span>))
<a name="l00202"></a>00202                     (this.Owner as MainForm).DataManager.Config[<span class="stringliteral">&quot;MT4&quot;</span>][<span class="stringliteral">&quot;storagePath&quot;</span>] = mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a54886ec28286d2b6a76b212a8ce18239">StoragePath</a>();
<a name="l00203"></a>00203                 
<a name="l00204"></a>00204                 <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Set(<span class="stringliteral">&quot;MT4SymbolsPath&quot;</span>, symbolsPath);
<a name="l00205"></a>00205                 List&lt;string&gt; symbols = getSymbolList(symbolsPath);
<a name="l00206"></a>00206                 <span class="keywordflow">foreach</span> (<span class="keywordtype">string</span> symbol <span class="keywordflow">in</span> symbols)
<a name="l00207"></a>00207                 {
<a name="l00208"></a>00208                     checkedListBox1.Items.Add(symbol);
<a name="l00209"></a>00209 
<a name="l00210"></a>00210                 }
<a name="l00211"></a>00211                 textBox2.Text = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00212"></a>00212                 mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a3588b6e2a02b1b9a9aab844d03f5d404">mt4init</a>();
<a name="l00213"></a>00213                 setList();
<a name="l00214"></a>00214             }
<a name="l00215"></a>00215             <span class="keywordflow">else</span>
<a name="l00216"></a>00216             {
<a name="l00217"></a>00217                 textBox2.Text = <span class="stringliteral">&quot;wrong account&quot;</span>;
<a name="l00218"></a>00218             }
<a name="l00219"></a>00219 
<a name="l00220"></a>00220         }
<a name="l00221"></a>00221 
<a name="l00227"></a>00227         <span class="keyword">private</span> List&lt;string&gt; getSymbolList(<span class="keywordtype">string</span> filePath)
<a name="l00228"></a>00228         {
<a name="l00229"></a>00229             <span class="keywordtype">int</span> symbolOffset = 116;
<a name="l00230"></a>00230             <span class="keywordtype">int</span> symbolRecordLength = 128;
<a name="l00231"></a>00231             <span class="keywordtype">int</span> symbolLength = 12;
<a name="l00232"></a>00232             List&lt;string&gt; symbols = <span class="keyword">new</span> List&lt;string&gt;();
<a name="l00233"></a>00233             FileStream fStream = <span class="keyword">new</span> FileStream(filePath, FileMode.Open, FileAccess.Read);
<a name="l00234"></a>00234             BinaryReader fReader = <span class="keyword">new</span> BinaryReader(fStream);
<a name="l00235"></a>00235             <span class="keywordtype">int</span> symbolsNumber = (((int)fStream.Length) - 4) / symbolRecordLength;
<a name="l00236"></a>00236             fReader.ReadBytes(4);
<a name="l00237"></a>00237             <span class="keywordtype">char</span>[] test;
<a name="l00238"></a>00238             <span class="keywordtype">string</span> symbol;
<a name="l00239"></a>00239             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; symbolsNumber; i++)
<a name="l00240"></a>00240             {
<a name="l00241"></a>00241                 test = fReader.ReadChars(symbolLength);
<a name="l00242"></a>00242                 fReader.ReadBytes(symbolOffset);
<a name="l00243"></a>00243                 symbol = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00244"></a>00244                 <span class="keywordflow">foreach</span> (<span class="keywordtype">char</span> c <span class="keywordflow">in</span> test)
<a name="l00245"></a>00245                 {
<a name="l00246"></a>00246                     <span class="keywordflow">if</span> (c == <span class="stringliteral">&#39;\x00&#39;</span>) <span class="keywordflow">break</span>;
<a name="l00247"></a>00247                     symbol = symbol + c.ToString();
<a name="l00248"></a>00248                 }
<a name="l00249"></a>00249                 symbols.Add(symbol);
<a name="l00250"></a>00250             }
<a name="l00251"></a>00251 
<a name="l00252"></a>00252             <span class="keywordflow">if</span> (fReader != null) fReader.Close();
<a name="l00253"></a>00253             <span class="keywordflow">if</span> (fStream != null) fStream.Close();
<a name="l00254"></a>00254 
<a name="l00255"></a>00255             <span class="keywordflow">return</span> symbols;
<a name="l00256"></a>00256         }
<a name="l00257"></a>00257 
<a name="l00258"></a>00258         <span class="keyword">private</span> <span class="keywordtype">void</span> setList()
<a name="l00259"></a>00259         {
<a name="l00260"></a>00260             <span class="keywordflow">foreach</span> (<a class="code" href="class_skilful_1_1_data_1_1_m_t_symbol.html">MTSymbol</a> symbol <span class="keywordflow">in</span> mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#aee3c5e6e8851054f79083b0cd4f13f11">mtSymbols</a>)
<a name="l00261"></a>00261             {
<a name="l00262"></a>00262                 <span class="keywordflow">if</span> (checkedListBox1.Items.Contains(symbol.<a class="code" href="class_skilful_1_1_data_1_1_m_t_symbol.html#a24e693526616a94e1a991265f46a103b">Symbol</a>) == <span class="keyword">true</span>)
<a name="l00263"></a>00263                 {
<a name="l00264"></a>00264                     checkedListBox1.SetItemChecked(checkedListBox1.Items.IndexOf(symbol.<a class="code" href="class_skilful_1_1_data_1_1_m_t_symbol.html#a24e693526616a94e1a991265f46a103b">Symbol</a>), <span class="keyword">true</span>);
<a name="l00265"></a>00265                 }
<a name="l00266"></a>00266             }
<a name="l00267"></a>00267         }
<a name="l00268"></a>00268 
<a name="l00269"></a>00269         <span class="keyword">private</span> <span class="keywordtype">void</span> checkedListBox1_SelectedIndexChanged(<span class="keywordtype">object</span> sender, EventArgs e)
<a name="l00270"></a>00270         {
<a name="l00271"></a>00271             List&lt;string&gt; mt4list = <span class="keyword">new</span> List&lt;string&gt;();
<a name="l00272"></a>00272             <span class="keywordflow">foreach</span> (<a class="code" href="class_skilful_1_1_data_1_1_m_t_symbol.html">MTSymbol</a> symbol <span class="keywordflow">in</span> mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#aee3c5e6e8851054f79083b0cd4f13f11">mtSymbols</a>)
<a name="l00273"></a>00273             {
<a name="l00274"></a>00274                 mt4list.Add(symbol.<a class="code" href="class_skilful_1_1_data_1_1_m_t_symbol.html#a24e693526616a94e1a991265f46a103b">Symbol</a>);
<a name="l00275"></a>00275                 <span class="comment">//MessageBox.Show(symbol.Symbol + &quot; - &quot; + symbol.Code);</span>
<a name="l00276"></a>00276             }
<a name="l00277"></a>00277             <span class="keywordflow">if</span> (mt4list.Contains(checkedListBox1.SelectedItem.ToString()) == <span class="keyword">false</span>)
<a name="l00278"></a>00278             {
<a name="l00279"></a>00279                 addSymbol(checkedListBox1.SelectedItem.ToString());
<a name="l00280"></a>00280             }
<a name="l00281"></a>00281             <span class="keywordflow">if</span> (mt4list.Contains(checkedListBox1.SelectedItem.ToString()) == <span class="keyword">true</span>)
<a name="l00282"></a>00282             {
<a name="l00283"></a>00283                 delSymbol(checkedListBox1.SelectedItem.ToString());
<a name="l00284"></a>00284                 ((MainForm)this.Owner).RefreshSymList(<span class="stringliteral">&quot;MT4&quot;</span>);
<a name="l00285"></a>00285             }
<a name="l00286"></a>00286         }
<a name="l00287"></a>00287 
<a name="l00292"></a>00292         <span class="keyword">private</span> <span class="keywordtype">void</span> addSymbol(<span class="keywordtype">string</span> addsymbol)
<a name="l00293"></a>00293         {
<a name="l00294"></a>00294             <span class="keywordtype">string</span> filePath = <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>);
<a name="l00295"></a>00295             filePath += <span class="stringliteral">&quot;\\experts\\files\\toget.skl&quot;</span>;
<a name="l00296"></a>00296             mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a7150fb451addebad8297fc7191d292f8">MaxCode</a>++;
<a name="l00297"></a>00297             <span class="comment">//MessageBox.Show(mtproxy.MaxCode.ToString());</span>
<a name="l00298"></a>00298             FileStream fStream = <span class="keyword">new</span> FileStream(filePath, FileMode.Append, FileAccess.Write);
<a name="l00299"></a>00299             StreamWriter fWriter = <span class="keyword">new</span> StreamWriter(fStream);
<a name="l00300"></a>00300             fWriter.WriteLine(addsymbol + delimiter + mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a7150fb451addebad8297fc7191d292f8">MaxCode</a>.ToString());
<a name="l00301"></a>00301             fWriter.Flush();
<a name="l00302"></a>00302             fWriter.Close();
<a name="l00303"></a>00303             fStream.Close();
<a name="l00304"></a>00304             mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a3588b6e2a02b1b9a9aab844d03f5d404">mt4init</a>();
<a name="l00305"></a>00305         }
<a name="l00306"></a>00306 
<a name="l00311"></a>00311         <span class="keyword">private</span> <span class="keywordtype">void</span> delSymbol(<span class="keywordtype">string</span> delsymbol)
<a name="l00312"></a>00312         {
<a name="l00313"></a>00313             List&lt;string&gt; symbols = <span class="keyword">new</span> List&lt;string&gt;();
<a name="l00314"></a>00314             <span class="keywordtype">string</span> filePath = <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>);
<a name="l00315"></a>00315             filePath += <span class="stringliteral">&quot;\\experts\\files\\toget.skl&quot;</span>;
<a name="l00316"></a>00316 
<a name="l00317"></a>00317             FileStream fStream = <span class="keyword">new</span> FileStream(filePath, FileMode.Truncate, FileAccess.Write);
<a name="l00318"></a>00318             StreamWriter fWriter = <span class="keyword">new</span> StreamWriter(fStream);
<a name="l00319"></a>00319 
<a name="l00320"></a>00320             <span class="keywordflow">foreach</span> (<a class="code" href="class_skilful_1_1_data_1_1_m_t_symbol.html">MTSymbol</a> temp <span class="keywordflow">in</span> mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#aee3c5e6e8851054f79083b0cd4f13f11">mtSymbols</a>)
<a name="l00321"></a>00321                 <span class="keywordflow">if</span> (temp.<a class="code" href="class_skilful_1_1_data_1_1_m_t_symbol.html#a24e693526616a94e1a991265f46a103b">Symbol</a> != delsymbol)   
<a name="l00322"></a>00322                     fWriter.WriteLine(temp.<a class="code" href="class_skilful_1_1_data_1_1_m_t_symbol.html#a24e693526616a94e1a991265f46a103b">Symbol</a> + delimiter + temp.<a class="code" href="class_skilful_1_1_data_1_1_m_t_symbol.html#ad7ed460bfcd91ef89e294e1dd29d314d">Code</a>);
<a name="l00323"></a>00323 
<a name="l00324"></a>00324             fWriter.Flush();
<a name="l00325"></a>00325             fWriter.Close();
<a name="l00326"></a>00326             fStream.Close();
<a name="l00327"></a>00327 
<a name="l00328"></a>00328 
<a name="l00329"></a>00329             <span class="keywordtype">string</span> folder_path = <a class="code" href="class_skilful_1_1_x_m_l_config.html">XMLConfig</a>.Get(<span class="stringliteral">&quot;MT4Path&quot;</span>) + <span class="stringliteral">&quot;\\experts\\files\\&quot;</span>;
<a name="l00330"></a>00330             DirectoryInfo di = <span class="keyword">new</span> DirectoryInfo(folder_path);
<a name="l00331"></a>00331             <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; 15; i++)
<a name="l00332"></a>00332             {
<a name="l00333"></a>00333                 <span class="keywordflow">try</span>
<a name="l00334"></a>00334                 {
<a name="l00335"></a>00335                     FileInfo[] filelist = di.GetFiles(delsymbol + <span class="stringliteral">&quot;*&#39;?&#39;?&quot;</span>); <span class="keywordflow">foreach</span> (FileInfo fi <span class="keywordflow">in</span> filelist) fi.Delete();
<a name="l00336"></a>00336                     filelist = di.GetFiles(delsymbol + <span class="stringliteral">&quot;*.csv&quot;</span>); <span class="keywordflow">foreach</span> (FileInfo fi <span class="keywordflow">in</span> filelist) fi.Delete();
<a name="l00337"></a>00337                 }
<a name="l00338"></a>00338                 <span class="keywordflow">catch</span> (Exception e)
<a name="l00339"></a>00339                 {
<a name="l00340"></a>00340                     <span class="keywordflow">if</span> (mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a706a7717fa86e4b454847318380282ca">dbg</a>) <a class="code" href="class_skilful_1_1_logging.html">Logging</a>.Log(<span class="stringliteral">&quot;Cannot delete &quot;</span> + delsymbol + <span class="stringliteral">&quot;(*&#39;?&#39;?/*.csv)\n&quot;</span> + e.Message);
<a name="l00341"></a>00341                     Thread.Sleep(100);
<a name="l00342"></a>00342                 }
<a name="l00343"></a>00343             }
<a name="l00344"></a>00344             mtproxy.<a class="code" href="class_skilful_1_1_data_1_1_m_tproxy.html#a3588b6e2a02b1b9a9aab844d03f5d404">mt4init</a>();
<a name="l00345"></a>00345         }
<a name="l00346"></a>00346     }
<a name="l00347"></a>00347 }
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>Указатель</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Классы</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Пространства имен</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Файлы</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Функции</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Переменные</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Перечисления</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Свойства</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>События</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Создано системой&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
